export default {
  tree_fp_nc_ods_sale_order: {
    _odoo_model: 'ir.ui.view',
    model: 'fp.nc.ods.sale.order',
    type: 'tree',
    buttons: { create: false, edit: false, delete: true },

    priority: 2,
    fields: {
      ods_order_id: { string: '订单号' },
      state: {},
      name: { string: 'NC发票PK' },
      invoice_num: { string: 'NC发票号' },
      biz_type: { string: 'NC类型' },
      company_code: {},
      company_name: {},
      partner_code: {},
      partner_name: {},

      amount_total: { string: '总金额' },
      api_status: { string: 'NC状态' },
      create_date: {}
    }
  },

  form_fp_nc_ods_sale_order: {
    _odoo_model: 'ir.ui.view',
    model: 'fp.nc.ods.sale.order',
    type: 'form',
    buttons: { create: false, edit: false, delete: true },

    toolbar: {
      action: {},
      print: {}
    },

    arch: {
      header: {
        buttons: [],
        fields: {}
      }
    },

    fields: {
      ods_order_id: { string: '订单号' },
      state: {},
      create_date: {},
      name: { string: 'NC发票PK' },
      invoice_num: { string: 'NC发票号' },
      biz_type: { string: 'NC类型' },

      company_code: {},
      company_name: {},
      partner_code: {},
      partner_name: {},

      amount_total: { string: '总金额' },
      api_status: { string: 'NC状态' },

      line_ids: {
        widget: 'x2many_tree',
        views: {
          tree: {
            fields: {
              // name: {},
              line_pk: { string: 'NC明细PK' },
              order_num: { string: 'NC订单号' },
              logistics_num: { string: '配载号' },
              sequence: { string: '序号' },
              product_categ_code: {},
              product_categ_name: {},

              product_code: {},
              product_name: {},
              product_spec: { string: '规格' },
              uom_name: { string: '单位' },
              tax_ratio: { string: '税率' },
              quantity: { string: '数量' },
              price_unit: { string: '单价' }
            }
          },

          form: {
            fields: {
              name: {},
              line_pk: { string: 'NC明细PK' },
              order_num: { string: 'NC订单号' },
              logistics_num: { string: '配载号' },
              sequence: { string: '序号' },
              product_categ_code: {},
              product_categ_name: {},

              product_code: {},
              product_name: {},
              product_spec: { string: '规格' },
              uom_name: { string: '单位' },
              tax_ratio: { string: '税率' },
              quantity: { string: '数量' },
              price_unit: { string: '单价' },
              note: { string: '备注' }
            }
          }
        }
      }
    }
  },

  search_fp_nc_ods_sale_order: {
    _odoo_model: 'ir.ui.view',
    model: 'fp.sale.order',
    type: 'search',
    arch: {
      fields: {
        name: {
          string: '单据',
          filter_domain: self => {
            return [
              '|',
              ['name', 'ilike', self],
              ['invoice_num', 'ilike', self]
            ]
          }
        },

        partner: {
          string: '客户',
          filter_domain: self => {
            return [
              '|',
              ['partner_code', 'ilike', self],
              ['partner_name', 'ilike', self]
            ]
          }
        },

        line_ids: {
          string: '明细',
          filter_domain: self => {
            return [
              '|',
              '|',
              '|',
              '|',
              ['line_ids.line_pk', 'ilike', self],
              ['line_ids.order_num', 'ilike', self],
              ['line_ids.logistics_num', 'ilike', self],
              ['line_ids.product_code', 'ilike', self],
              ['line_ids.product_name', 'ilike', self]
            ]
          }
        }
      },

      filters: {
        group1: {
          state_done: {
            string: '导入成功',
            domain: [['state', 'in', ['done']]]
          },
          state_error: {
            string: '导入错误',
            domain: [['state', 'in', ['error']]]
          }
        },
        group2: {
          api_status_confirm: {
            string: '单据确认',
            domain: [['api_status', 'in', ['confirm']]]
          },
          api_status_cancel: {
            string: '单据取消',
            domain: [['api_status', 'in', ['cancel']]]
          }
        },

        group3: {
          biz_type_sale: {
            string: '销售单据',
            domain: [['biz_type', 'in', ['sale']]]
          },
          biz_type_refund: {
            string: '退货单据',
            domain: [['biz_type', 'in', ['refund']]]
          },
          biz_type_discount: {
            string: '折扣单据',
            domain: [['biz_type', 'in', ['discount']]]
          }
        },

        group9: {
          filter_create_date: { string: '创建日期', date: 'create_date' }
        }
      }
    }
  },

  action_fp_nc_ods_sale_order: {
    _odoo_model: 'ir.actions',
    name: '销售订单',
    type: 'ir.actions.act_window',
    res_model: 'fp.nc.ods.sale.order',
    search_view_id: 'search_fp_nc_ods_sale_order',
    domain: [],
    context: {},
    views: {
      tree: 'tree_fp_nc_ods_sale_order',
      form: 'form_fp_nc_ods_sale_order'
    }
  }
}
